<?php session_start(); ?>
<!DOCTYPE html>
<html>
	<!-- HEAD -->
<?php include('header.php') ?>
<?php include('3_PHP/buy.php'); ?>
<?php require_once('3_PHP/connexionPDO.php'); ?>
	
	
	
	<!-- BODY -->
	<body>
		<!-- NAVIGATION -->
<?php include ('navigation.php') ?>
		
		
		
		<!-- MAIN -->
		<div id="main_body">
			<h1>YOUR CART</h1>
			<h4>
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
				Aliquam et nisl orci, nec interdum eros. Nunc a odio 
				suscipit neque aliquam vestibulum. Nullam sed diam est, 
				molestie tristique ipsum. Curabitur rutrum, sapien eu dictum 
				vehicula, metus lectus lobortis mi, nec tincidunt orci sem eu dolor. 
				Nunc quis mi nec ligula vehicula bibendum nec sed mauris.
			</h4>
			<div id="cart_products_container">
				<div class="rectangle_container">
					<?php
					if(!empty($_SESSION['products']))
					{
						foreach ($_SESSION['products'] as $idProduct => $number) {
							if ($number > 0 ) {			
								$result = getProduct($pdo,$idProduct);
								$totalPrice += ( $result['price'] * $number);
								$price = $result['price'] * $number;
						?>
								<div class="cart_products_list_group">
									<div class="cart_products_list">
										<div class="product_cathegory">	Item:							</div>
										<div class="product_value">		<?php echo $result['title'] ?>	</div>
									</div>
									<br>
									<div class="cart_products_list">
										<div class="product_cathegory">	Unit price:						</div>
										<div class="product_value">		<?php echo $result['price']	?>	</div>
									</div>
									<br>
									<div class="cart_products_list">
										<div class="product_cathegory">	Quantity:						</div>
										<div class="product_value">		<?php echo $number ?>			</div>
									</div>
									<br>	
									<div class="cart_products_list">
										<div class="product_cathegory">	Sub-total:						</div>
										<div class="product_value">		<?php echo $price ?>			</div>
									</div>
									<br>
								</div>
								<div class="product_action_buttons">
										<form method="post">
											Quantity:
											<input type="hidden" name="Add" value="<?php echo  $idProduct ?>">
											<button class="bouton_buy" type="button"> +1 </button>
										</form>
										<form method="post">
											<input type="hidden" name="Remove" value="<?php echo $idProduct ?>">
											<button class="bouton_buy" type="button"> -1 </button>
										</form>
								</div>
								<br>
						<?php
							}
						}
					?>
						<div class="divider"></div>
						<div id="cart_products_total">
							<div class="product_cathegory">	TOTAL PRICE:						</div>
							<div class="product_value">		<?php echo $totalPrice?>			</div>
						</div>
						<div id="validate_cart">
							<form method="post">
								<input type="hidden" name="Buy" value="<?php echo  $idProduct ?>">
								<button class="bouton_buy_item" type="button">Validate Cart &#38; Check Out</button>
							</form>
						</div>
				<?php
					}
				?> 
				</div>
			</div>
		</div>

		
		
		<!-- FOOTER -->
<?php include('footer.php') ?>
</html>